<?php
defined('BASEPATH') OR exit('No direct script access allowed');


use QCloud_WeApp_SDK\Mysql\Mysql as DB;


class CartAdd extends CI_Controller
{
    public function index()
    {
        $unionid = $_GET['unionid'];
        $name = $_GET['name'];
        $goods_id = $_GET['goods_id'];
        $number = $_GET['number'];
        $price = $_GET['price'];
        $pic = $_GET['pic'];

        $rows = null;
        if ($unionid) {
            $rows = DB::insert('cc_cart', ['unionid' => $unionid, 'name' => $name,
                'goods_id' => $goods_id, 'number' => $number, 'price' => $price, 'pic' => $pic]);

        }
        if ($rows>0) {
            $this->json([
                'code' => 0,
                'data' => $rows
            ]);
        } else {
            $this->json([
                'code' => -1,
                'error' => $rows['error']
            ]);
        }
    }
}
